package eerbaar.v2.app.view;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.Rectangle;

public class Square {

    private final Rectangle rectangle;
    private final int x;
    private final int y;

    public Square(Rectangle rectangle, int x, int y) {
        this.rectangle = rectangle;
        this.x = x;
        this.y = y;
    }

    public void draw(Graphics2D g) {

        // Graphics2D g = (Graphics2D) canvas.getBufferStrategy()
        // .getDrawGraphics();
        // g.setColor(Color.BLACK);
        // g.drawRect(this.rectangle.x, this.rectangle.y, this.rectangle.width,
        // this.rectangle.height);
    }

    public Rectangle getRectangle() {
        return this.rectangle;
    }

    public int getX() {
        return this.x;
    }

    public int getY() {
        return this.y;
    }

    public void highlight(Graphics2D g) {

        // Graphics2D g = (Graphics2D) canvas.getBufferStrategy()
        // .getDrawGraphics();

        Composite save = g.getComposite();

        int type = AlphaComposite.SRC_OVER;
        AlphaComposite alpha = AlphaComposite.getInstance(type, 0.4f);
        g.setComposite(alpha);

        g.setColor(Color.YELLOW);
        g.fillRoundRect(this.rectangle.x + 1, this.rectangle.y + 1,
                this.rectangle.width - 2, this.rectangle.height - 2, 10, 10);

        g.setComposite(save);
    }

}
